1. Install Apache using Ubuntu's package manager, apt:
$ sudo apt update
$ sudo apt install apache2Modify apache to allow URL rewrites:
sudo nano /etc/apache2/sites-available/000-default.confCreate a directory section where we allow overrides:
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
ServerName server_domain_name_or_IP
<Directory /var/www/html/>
AllowOverride All
</Directory>
. . .sudo a2enmod rewritesudo systemctl restart apache22. Install MariaDB
$ sudo apt install mariadb-server mariadb-client3. Secure MariDB
$ sudo mysql_secure_installation4. Install PHP
$ sudo apt install php libapache2-mod-php php-mysqlWe want to tell the web server to prefer PHP files over others, so make Apache look for an index.php file first:
$ sudo nano /etc/apache2/mods-enabled/dir.confMove the PHP index file to the first position after the DirectoryIndex specification, like this:
<IfModule mod_dir.c>
DirectoryIndex index.php index.html index.cgi index.pl index.xhtml index.htm
</IfModule>Ctrl+x, the ‘y' to save and exit. Restart the Apache web server:
$ sudo systemctl restart apache25. Install phpMyAdmin
$ sudo apt install phpmyadminOn the first prompt, select ‘apache2' by pressing the space bar then the ‘tab' key. Press the ‘enter' key to accept. On the following prompt, refuse the option to configure database for phpmyadmin.
Log into MariaDB
$ sudo mysqlCreate a new user and give it a strong password:
MariaDB [(none)]> CREATE USER 'yourusername'@'localhost' IDENTIFIED BY 'password';Then, grant your new user appropriate privileges. For example, you could grant the user privileges to all tables within the database, as well as the power to add, change, and remove user privileges, with this command:
MariaDB [(none)]> GRANT ALL PRIVILEGES ON *.* TO 'yourusername'@'localhost' WITH GRANT OPTION;Following that, exit the MariaDB shell:
MariaDB [(none)]> exitYou can now access the web interface by visiting your server's domain name or public IP address followed by /phpmyadmin:
https://your_domain_or_IP/phpmyadmin6. Secure phpMyAdmin (optional)
Edit the linked file that has been placed in your Apache configuration directory:
$ sudo nano /etc/apache2/conf-available/phpmyadmin.confAdd an ‘AllowOverride All' directive within the <Directory /usr/share/phpmyadmin> section of the configuration file, like this:
<Directory /usr/share/phpmyadmin>
Options FollowSymLinks
DirectoryIndex index.php
AllowOverride All
. . .When you have added this line, Ctrl+x, then ‘y' to save and close the file. Restart Apache:
$ sudo systemctl restart apache2see more at https://www.digitalocean.com/community/tutorials/how-to-install-and-secure-phpmyadmin-on-ubuntu-18-04